﻿Element.prototype.PerformRecursive = function PerformRecursive(action, doMyself)
{
	if (doMyself === true)
		action(this);

	var childNodes = this.get_ChildNodes();
	for (var i = 0; i < childNodes.length; ++i)
	{
		var node = childNodes[i];

		if (node.nodeName == "#text") continue;

		if (action(node) === true)
			return true;

		if (node.childNodes.length > 0)
		{
			if (node.PerformRecursive(action) === true)
				return true;
		}
	}
	return false;
}
